import java.io.*;
import java.util.*;

public class SquareTiles {
	public static void main(String args[]){
		try{
			Scanner sc = new Scanner(new File("A-large.in"));//入力ファイル
			PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(new File("solve.in"))));//出力ファイル
			int T = sc.nextInt();//ループ回数
			for(int i=1;i<=T;i++){
				int R = sc.nextInt();
				int C = sc.nextInt();
				String[] pic = new String[R];
				boolean check=true;
				for(int j=0;j<R;j++)pic[j]=sc.next();
				for(int j=0;j<R;j++){
					for(int k=0;k<C;k++){
						if(pic[j].charAt(k)=='#'){
							if(j != R-1 && k!=C-1 && pic[j].charAt(k+1)=='#' && 
									pic[j+1].charAt(k)=='#' && pic[j].charAt(k+1)=='#'){
								if(k+2<=C){
									pic[j] = pic[j].substring(0,k).concat("/\\").concat(pic[j].substring(k+2, C));
									pic[j+1] = pic[j+1].substring(0,k).concat("\\/").concat(pic[j+1].substring(k+2, C));
								}else{
									pic[j] = pic[j].substring(0,k).concat("/\\");
									pic[j+1] = pic[j+1].substring(0,k).concat("\\/");									
								}
							}else check=false;
						}
					}
				}
				
				
				pw.println("Case #"+i+": ");//出力
				if(check){
					for(int j=0;j<R;j++){
						pw.println(pic[j]);
					}
				}else pw.println("Impossible");
			}
			pw.close();
		}catch(FileNotFoundException e){
			System.out.println(e);
		}catch(IOException e){
			System.out.println(e);			
		}
	}

}
